#!/bin/bash
mkdir -p ${HOME}/backup
cp ${HOME}/left4dead2/left4dead2/left4dead2/cfg {HOME}/backup/
cp ${HOME}/left4dead2/left4dead2/left4dead2/addons/sourcemod/plugins {HOME}/backup/
cp ${HOME}/left4dead2/left4dead2/left4dead2/addons/sourcemod/gamedata {HOME}/backup/
cp -v cfg/superversus.cfg ${HOME}/left4dead2/left4dead2/left4dead2/cfg
cp -v cfg/sourcemod/*.cfg ${HOME}/left4dead2/left4dead2/left4dead2/cfg/sourcemod
cp -v signatures/*.txt ${HOME}/left4dead2/left4dead2/left4dead2/addons/sourcemod/gamedata/
cp -v addons/*.vpk ${HOME}/left4dead2/left4dead2/left4dead2/addons/
cp -rv include/* ${HOME}/left4dead2/left4dead2/left4dead2/addons/sourcemod/scripting/include/
cp -v additional/* ${HOME}/left4dead2/left4dead2/left4dead2/addons/sourcemod/scripting/
cd plugins
for i in $(ls . | grep -v build.sh | grep -v install.sh | grep -v compiled | grep -v "*.sp~")
do
    ./build.sh $i
    if test "$?" -eq 0
    then
	./install.sh $i
    else
	exit
    fi
done

echo -e  "all is installed except server.cfg (don't have rcon password !)"
